﻿using System;
using System.Configuration;

namespace Alex.Library.Log.Configuration
{
    /// <summary>
    /// 自定义日志元素
    /// </summary>
    public class CustomLoggerElement : LoggerElement
    {
        /// <summary>
        /// 适配器元素
        /// </summary>
        [ConfigurationProperty("adapter", IsRequired = true)]
        public FlushAdapterElement Adapter
        {
            get
            {
                return (FlushAdapterElement)this["adapter"];
            }
        }

        /// <summary>
        /// 根据配置获取自定义日志对象
        /// </summary>
        /// <returns></returns>
        public override ILogger GetLogger()
        {
            IFlushAdapter adapter = this.Adapter.GetAdapterObject();
            CustomLogger cl = new CustomLogger(adapter);
            return cl;
        }
    }
}
